<template>
  <chart height="400px" v-if="option" :option="option"></chart>
</template>

<script>
export default {
  name: "QuestionType",
  props: ["questionInfo"],
  data() {
    return {
      option: null
    };
  },
  created() {
    const types = this.questionInfo.map(item => item.name);
    this.option = {
      title: {
        text: "考试系统试题类型汇总",
        left: "center"
      },
      tooltip: {
        trigger: "item",
        formatter: "{a} <br/>{b} : {c} ({d}%)"
      },
      legend: {
        orient: "vertical",
        left: "left",
        data: types
      },
      series: [
        {
          name: "试题类型",
          type: "pie",
          radius: "55%",
          center: ["50%", "60%"],
          data: this.questionInfo
        }
      ]
    };
  }
};
</script>

<style scoped></style>
